﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GDIScreenCapture
{
    public class ComputerScreen
    {
        public ComputerScreen()
        {

        }

        /// <summary>
        /// 获取到屏幕的大小
        /// </summary>
        /// <returns></returns>
        public Size GetScreenSize()
        {
            return Screen.PrimaryScreen.Bounds.Size;
        }

        /// <summary>
        /// 截取整个屏幕
        /// </summary>
        /// <returns></returns>
        public Bitmap PrintScreen()
        {
            Size size = this.GetScreenSize();
            Bitmap bmp = new Bitmap(size.Width, size.Height);
            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.CopyFromScreen(0, 0, 0, 0, size);
            }
            bmp.Save("temp.png");
            return bmp;
        }
    }
}
